/**
 * 
 */
package com.teach.service.impl;

import com.teach.dao.UserDAO;
import com.teach.entity.User;
import com.teach.exception.CodeException;
import com.teach.service.UserLoginService;

/**
 * -- 用户登录的业务逻辑实现类
 * @author Liulianqiu
 *2020年8月6日
 */
public class UserLoginServiceImpl implements UserLoginService {

	private UserDAO user1 = new UserDAO();
	@Override
	public User login(String userName, String userPassword) throws CodeException { 
		//用户不存在
		User user = new User();
		try {
			user = user1.selectByUserName(userName);
		} catch (Exception e) {
			throw new CodeException(1,"用户不存在", e);
		}
		//密码错误
		if(!(Integer.toString(user.getLlq_age())).equals(userPassword)) {
			throw new CodeException(2,"密码错误");
		}
		return user;
	}

}
